<template>
  <div class="movie_body">
    <loading v-if="flag"></loading>
    <Scroll v-else>
      <ul>
        <!-- <li>
        <div class="pic_show">
          <img src="/images/movie_1.jpg" />
        </div>
        <div class="info_list">
          <h2>无名之辈</h2>
          <p>
            <span class="person">17746</span> 人想看
          </p>
          <p>主演: 陈建斌,任素汐,潘斌龙</p>
          <p>2018-11-30上映</p>
        </div>
        <div class="btn_pre">预售</div>
      </li>
        -->
        <li v-for="item in comingList" :key="item.id">
          <div class="pic_show"  @tap="handlToDetail(item.id)">
            <!-- <img :src="item.img | setWH('128.180')" /> -->
            <img :src="item.img" />
          </div>
          <div class="info_list">
            <h2  @tap="handlToDetail(item.id)">{{item.nm}}</h2>
            <img v-if="item.version" src="@/assets/maxs.png" alt />
            <p>
              <span class="person">{{item.wish}}</span> 人想看
            </p>
            <p>主演: {{item.start}}</p>
            <p>{{item.rt}}上映</p>
          </div>
          <div class="btn_pre">预售</div>
        </li>
      </ul>
    </Scroll>
  </div>
</template>

<script>
//实现上拉加载更多也是一个道理的
import { getcominglsit } from "network/comingsoon";
import Scroll from "components/Srcoll/srcoll";
import loading from "components/Loading";
export default {
  name: "ComingSoon",
  components: {
    Scroll,
    loading
  },
  data() {
    return {
      comingList: [],
      flag:true,
      prevCityid:-1
    };
  },
    // 组件活跃到时候执行
  activated() {
    var cityid = this.$store.state.city.id;
    if(this.prevCityid === cityid) {return;} //如果相等就说明不执行 直接组件本生命周期的函数
    //点击城市的时候就发送id过去替换新的数据  切换的时候 再次发送请求
    this.flag =true
    this.getmovielist(cityid);
  },
  mounted() {
    var cityid = this.$store.state.city.id;
    this.getcominglsit(cityid);
  },

  methods: {
    getcominglsit(cityid) {
      getcominglsit(cityid).then((res) => {
        // console.log(res);
        // var msg = res.msg;
        // if (msg === "ok") {
           // this.flag = false
        //   this.comingList = res.data.comingList;
        // }
      });
    },
       //tap事件 要配置bterll-srcoll事件才行 跳转详情页的
    handlToDetail(id) {
      this.$router.push('/movie/detail/2/' + id)
    },

  },
};
</script>

<style>
</style>